<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>history路由：浏览器的BOM的api</title>
  </head>
  <body>
    <a href="www.baidu.com" onclick="return push('/test1')">push test1</a><br /><br />
    <button onclick="push('/test02')">push test02</button><br /><br />
    <button onclick="replace('/test03')">replace test03</button><br /><br />
    <button onclick="back()">&lt;后退</button>
    <button onclick="forward()">&gt;前进</button>

    <script src="https://cdn.bootcdn.net/ajax/libs/history/4.7.2/history.js"></script>
    <script>
      // let history = History.createBrowserHistory()
      let history = History.createHashHistory()
      function push(path) {
        history.push(path)
        return false
      }

      function replace(path) {
        history.replace(path)
      }

      function back() {
        history.goBack()
      }

      function forward() {
        history.goForward()
      }
    </script>
  </body>
</html>
